<?php
require_once 'includes/config.php';
require_once 'includes/functions.php';
require_once 'includes/class.phpmailer.php';

if(!empty($_POST['submit']))
{
	$businessName		=	$_REQUEST['businessName'];
	if(isset($_REQUEST['special_in']))
	$specialin		=	$_REQUEST['special_in'];
	else
	$specialin		=	"";
	$btype			=	$_REQUEST['btype'];
	$businessDescription	=	$_REQUEST['businessDescription'];
	$address1		=	$_REQUEST['address1'];
	//$address2		=	$_REQUEST['address2'];
	$city			=	$_REQUEST['city'];
	$state			=	$_REQUEST['state'];
	$country		=	$_REQUEST['country'];
	$zip			=	$_REQUEST['zip'];
	$phoneNo1		=	$_REQUEST['phoneNumber1']."-".$_REQUEST['phoneNumber2']."-".$_REQUEST['phoneNumber3'];
	if(!empty($_REQUEST['extension1']))
		$phoneNo1.= 	"-".$_REQUEST['extension1'];
	$email			=	$_REQUEST['email'];	
	$firstName		=	$_REQUEST['firstName'];
	$lastName		=	$_REQUEST['lastName'];
	$phoneNo2	        =	$_REQUEST['phoneNumber4']."-".$_REQUEST['phoneNumber5']."-".$_REQUEST['phoneNumber6'];
	if(!empty($_REQUEST['extension2']))
		$phoneNo2.="-".$_REQUEST['extension2'];
	$businessEmail		=	$_REQUEST['businessEmail'];
	$driverLicence		=	$_REQUEST['driverLicence'];
	$userName		=	$_REQUEST['userName'];
	$password		=	$_REQUEST['password'];
	$secretQuestion		=	$_REQUEST['secretQuestion'];
	$secretAnswer		=	$_REQUEST['secretAnswer'];
	$dob			=	$_REQUEST['dYear']."-".$_REQUEST['dMonth']."-".$_REQUEST['dDay'];
	$currentDate		=	date("Y-m-d");
	
	if(is_numeric($state)) {
		$state 		= 	getStateName($state);
	} 
	if(is_numeric($city)) {
		$city 		= 	getCityName($city);
	}


	//$phoneNumber=$_REQUEST['phonenumber'];
	$sqlSelUsr = "select * from tbl_users where username='".$userName."'";
	$rstSelUsr = mysql_query($sqlSelUsr) or die(mysql_error());
	$noSelUsr = @mysql_num_rows($rstSelUsr);
	if($noSelUsr==0)
	{
			  $confirmCode=get_rand_id(5);
			
              $matchCriteria='';
			  $sameDOB=mysql_num_rows(mysql_query("SELECT * FROM tbl_users WHERE dob='".$dob."' AND user_type=5 AND (denyStatus=1 OR status=4)"));
			  if($sameDOB>0)
			  {
				 $matchCriteria.='Date of Birth, ';
			  }
			  
			  $sameEmail=mysql_num_rows(mysql_query("SELECT * FROM tbl_users WHERE email='".$email."' AND user_type=5 AND (denyStatus=1 OR status=4)"));
			  if($sameEmail>0)
			  {
				 $matchCriteria.='Email, ';
			  }
			  
			  $sameFname=mysql_num_rows(mysql_query("SELECT * FROM tbl_users WHERE (first_name='%".$firstName."%' OR first_name='".$firstName."') AND user_type=5 AND (denyStatus=1 OR status=4)"));
			  if($sameFname>0)
			  {
				 $matchCriteria.='First Name, ';
			  }
			  
			  $sameLname=mysql_num_rows(mysql_query("SELECT * FROM tbl_users WHERE (last_name='%".$lastName."%' OR last_name='".$lastName."') AND user_type=5 AND (denyStatus=1 OR status=4)"));
			  if($sameFname>0)
			  {
				 $matchCriteria.='Last Name, ';
			  }

			  $sameFirstLastName=mysql_num_rows(mysql_query("SELECT * FROM tbl_users WHERE (first_name='%".$firstName."%' OR first_name='".$firstName."') AND (last_name='%".$lastName."%' OR last_name='".$lastName."') AND user_type=5 AND (denyStatus=1 OR status=4)"));
			  if($sameFirstLastName>0)
			  {
				 $matchCriteria.='First Name and Last Name, ';
			  }
			  
			  $sameBusinessName=mysql_num_rows(mysql_query("SELECT * FROM tbl_users WHERE (business_name='%".$businessName."%' OR business_name='".$businessName."') AND user_type=5 AND (denyStatus=1 OR status=4)"));
			  if($sameBusinessName>0)
			  {
				 $matchCriteria.='Business Name, ';
			  }
			  
			  $sameBusinessAddress=mysql_num_rows(mysql_query("SELECT * FROM tbl_users WHERE (address_line_1='%".$address1."%' OR address_line_1='".$address1."') AND user_type=5 AND (denyStatus=1 OR status=4)"));
			  if($sameBusinessAddress>0)
			  {
				 $matchCriteria.='Business Address, ';
			  }

            $wholesaler_match_criteria=substr($matchCriteria, 0, strlen($matchCriteria)-2);
			
			$subject="Swapen Registration :: Wholesaler information matched";
			$message="A new member registered as a wholesaler.".$wholesaler_match_criteria ." matched in database with another wholesaler registered before.";
			$headers = "From: ".$firstName."<".$email."> \r\n";
			$headers .= 'MIME-Version: 1.0' . "\r\n";
			$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
			mail("support@swapen.com",$subject, $message, $headers);
			
			
			$sqlInsTmpUsr="INSERT INTO tbl_temp_user SET  
  					business_name='".sanitize($businessName)."', 
  				 	username='".sanitize($userName)."',
					password='".$password."',
					user_type=5,
					confirmation_code='".$confirmCode."',
					first_name='".sanitize($firstName)."',
					last_name='".sanitize($lastName)."',
					address_line_1='".sanitize($address1)."',
					address_line_2='".sanitize($address2)."',
					secret_question=".$secretQuestion.",
					secret_answer='".sanitize($secretAnswer)."',
					city='".$city."',
					state='".$state."',
					country='".$country."',
					zip='".$zip."',
					phone_number_1='".$phoneNo1."',
					phone_number_2='".$phoneNo2."',
					email='".$email."',
					businessEmail='".$businessEmail."',
					driverLicence='".$driverLicence."',
					dob='".$dob."',
					status=1,
					special_in='".$specialin."',
					created_date='".$currentDate."'";
			$rstInsTmpUsr = mysql_query($sqlInsTmpUsr) or die(mysql_error());
			$insertedId=mysql_insert_id();
			if($insertedId!='' && $insertedId>0)
			{
				if($cnt>0)
				{
					  $msg1="<table width='100%' border='0'>
				      <tr>
					<td width='71%' ><p><b>Hi Support team, </b> </p>
					<p>Following user's registration info is matching to user which is closed by swapen Admin.</p></td>
				      </tr>
				      <tr>
					<td width='100%' >
					    <b>Username:</b>".$userName."<br/>
					    <b>Email:</b>".$email."<br/>
					    <b>First name:</b>".$firstName."<br/>
					    <b>Last name:</b>".$lastName."<br/>
					</td>
				      </tr>
				    </table>";
				    $email1="swapen@iceincorp.com,support@swapen.com,vikas@adroitcoders.com";
				    $mail = new PHPMailer(); // defaults to using php "mail()"
					      $mail->MsgHTML($msg1);
					      $mail->From       = "mail@swapen.com";
					      //$mail->From       = "vikas@adroitcoders.com";
					      $mail->FromName   = "Swapen.com";
					      $mail->Subject    = "Merchant/Whole seller Account info. matching to closed user";
					      $mail->AddAddress($email1);
					      $mail->Send();
				}
			     
				$msg="<table width='100%' border='0' style='font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px; line-height:25px'>
				<tr>
				  <td width='18%' height='41'><table width='100%' border='0'>
				    <tr>
				      <td width='19%' height='68'><img src='".$base_url."images/logo.png' width='208' height='83'></td>
				      <td width='81%'>Swapen sent this message to <b>".$firstName." ".$lastName."  ( ".$userName." )</b> <br>
			      Your registered name is included to show this message originated from Swapen. </td>
				    </tr>
				  </table></td>
				</tr>
				<tr>
				  <td height='32' colspan='2' style='font-family:Verdana, Arial, Helvetica, sans-serif;font-size:13px;color:#FFFFFF;background-color:#0FB6FA;'><b>&nbsp;&nbsp;Complete your Swapen registration</b></td>
				</tr>
				<tr>
				  <td>
				    <table width='100%' border='0'>
				      <tr>
					<td width='71%' height='124'><p><b>Hi ".$firstName." ".$lastName." </b>, </p>
					<p>Just click 'Activate Now' to complete your registration. That's all there is to it. After that, you are ready to start using Swapen.com</p></td>
					<td width='29%' style='text-align:center'><b>This is the last step, we promise!</b><a href='".$base_url."index.php?confirm&cnc=".$confirmCode."&usn=".$userName."' target='_blank' style='text-decoration:none; color:#FFFFFF'><img src='".$base_url."images/activate_now.gif' width='138' height='43'></a></td>
				      </tr>
				    </table>
				  </td>
				</tr>
				<tr>
				  <td><table width='100%' border='0'>
				    <tr>
				      <td height='28' style='background-color:#F3F3F3'><b>If the above link does not work:</b></td>
				    </tr>
				    <tr>
				      <td height='80'>Type in or copy and paste this link into your Web browser: <br>
					<a href='".$base_url."index.php?confirm&cnc=".$confirmCode."&usn=".$userName."' target='_blank'>".$base_url."index.php?confirm&cnc=".$confirmCode."&usn=".$userName."</a><br></td>
				    </tr>
				  </table></td>
				</tr>
			      </table>";
				$mail = new PHPMailer(); // defaults to using php "mail()"
				$mail->MsgHTML($msg);
				$mail->From       = "registration@swapen.com";
				$mail->FromName   = "Swapen Activation";
				$mail->Subject    = "Complete your Swapen Registration--last step";
				$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
				$mail->AddAddress($email, $firstName);
				$mail->Send();
				$msg="<font color='#005B00'>successfully registered, Check your email for confirmation.</font>";
			}
			else
				$msg="<font color='#FF0000'>Problem in registration, Try again.</font>";
		}
	else
    {
			$sqlInsTmpUsr="INSERT INTO tbl_temp_user SET  
  					business_name='".sanitize($businessName)."', 
  				 	username='".sanitize($userName)."',
					password='".$password."',
					user_type=5,
					confirmation_code='".$confirmCode."',
					first_name='".sanitize($firstName)."',
					last_name='".sanitize($lastName)."',
					address_line_1='".sanitize($address1)."',
					address_line_2='".sanitize($address2)."',
					secret_question=".$secretQuestion.",
					secret_answer='".sanitize($secretAnswer)."',
					city='".$city."',
					state='".$state."',
					country='".$country."',
					zip='".$zip."',
					phone_number_1='".$phoneNo1."',
					phone_number_2='".$phoneNo2."',
					email='".$email."',
					businessEmail='".$businessEmail."',
					driverLicence='".$driverLicence."',
					dob='".$dob."',
					status=4,
					special_in='".$specialin."',
					created_date='".$currentDate."'";
			$rstInsTmpUsr = mysql_query($sqlInsTmpUsr) or die(mysql_error());
	 
	 $subject="Your New Account is Inactive";
	 $sqlEmail2="select * from tbl_emails where email_type='Register in closed account'";
	 $resEmail2=mysql_query($sqlEmail2);
	 $rowEmail2=mysql_fetch_array($resEmail2);
	 $message=str_replace('%fname%',$firstName,str_replace('%lname%',$lastName,$rowEmail2['email_body']));
	 $headers = "From: Swapen.com<mail@swapen.com> \r\n";
	 $headers .= 'MIME-Version: 1.0' . "\r\n";
	 $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
	 mail($email,$subject, $message, $headers);
	 
	 $subject2="New member has registered with old user account info";
	 $sqlEmail3="select * from tbl_emails where email_type='Register in closed account for admin'";
	 $resEmail3=mysql_query($sqlEmail3);
	 $rowEmail3=mysql_fetch_array($resEmail3);
	 $fullname=$firstName." ".$lastName;
	 $message2=str_replace('%username%',$userName,$rowEmail3['email_body']);
	 $headers2 = "From: ".$fullname."<".$email."> \r\n";
	 $headers2 .= 'MIME-Version: 1.0' . "\r\n";
	 $headers2 .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
	 mail("support@swapen.com",$subject2, $message2, $headers2);
		//$msg="<font color='#FF0000'>Same username already exist, Choose any other username.</font>";
   }
	
}
?>
<script src="<?php echo $base_url?>js/jquery-1.4.4.js" type="text/javascript"></script>
<script src="<?php echo $base_url?>js/jquery.custom_radio_checkbox.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
	$(".radio").dgStyle();
	$(".checkbox").dgStyle();
});
</script>


<div id='panel'>
<form name="frmRegisterMerchant" id="frmRegisterMerchant" method="post" action="index.php?registerWholeseller" onsubmit="return validateRegisterMerchant()">
<input type="hidden" name="registerMerchantKey" id="registerMerchantKey" />

<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
	<div class="releftbox_out">
	<div class="releftbox_top">&nbsp;</div>
	<div class="releftbox_repeat">

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
	<td align="center"><img src="<?php echo $base_url?>images/register_images/register_wholesalerac.png" align="absmiddle" /></td>
  </tr>
  <tr>
	<td align="center">Already registered or want to make changes to your account? <a href="index.php?signin">Sign in. </a></td>
  </tr>
  <tr>
	<td>
		<div id="messageAreaTop" style="margin:10px 0px 10px 20px; float:left;"><?php if(isset($msg)) echo "<b>".$msg."</b>"; ?></div>
		
		<div class="blue_box">
			<div class="bluebar_left"></div>
			<div class="bluebar_center"><span>Tell us about your business-(required)</span></div>
			<div class="bluebar_right"></div>
		</div>
		
		<div class="blue_box">
			<div class="form_field_box">
				<label for="businessName" id="lblBusinessName" >Business Name:</label>
				<span>
				
				<input type="text" name="businessName" id="businessName" value="<?php echo $_REQUEST['businessName']?>" class="inputbg" style="width:150px;" />
				
				</span>
			</div>
			<div class="form_field_box">
				<label for="special_in" id="lblspecial_in">Specialize In:</label>
				<span>
				
				<input type="text" name="special_in" id="special_in"  value="<?php echo $_REQUEST['special_in']?>" class="inputbg" style="width:150px;"  />
				
				</span>
			</div>
		</div>
		<div class="blue_box">
			<div class="form_field_box_full">
				<label for="address1" id="lblAddress1">Business Address:</label>
				<span>
				
				<input type="text" name="address1" id="address1" value="<?php echo $_REQUEST['address1']?>" class="inputbg" style="width:150px;" />
				
				</span>
			</div>
		</div>
		<div class="blue_box">
			<div class="form_field_box">
				<label for="country" id="lblCountry">Country:</label>
				<span>
					<select name="country" id="country" onChange="javascript:funSelectState(this.value,'selectedState','1')" style="width:145px; height:28px;">
						<option value="">Select country...</option> 
						<?php			   
						$sqlSelCountry="SELECT * FROM tbl_country where code='US'";
						$rstSelCountry=mysql_query($sqlSelCountry);
						while($rowSelCountry=mysql_fetch_array($rstSelCountry))
						{
							$cty_id=$rowSelCountry['country_id'];
							$cty_name=$rowSelCountry['country_name'];
							echo "<option value='$cty_id' selected='selected'>$cty_name</option>";
						}
						?>
					</select>
				</span>
			</div>
			<div class="form_field_box">
				<label for="state "id="lblState">State:</label>
				<span id="selectedState">
				
					<select name="state" id="state" style="width:145px; height:28px;" class="inputbg">
						<option value="">Select state...</option>
						<?php
						if($_REQUEST['country']!='')
						{
							$qry = mysql_query("select stateid , statename,country_id from tbl_state where country_id='".$_REQUEST['country']."'") or die(mysql_error());
							$cnt_qry =  mysql_num_rows($qry);
							if($cnt_qry > 0)
							{
								while($row = mysql_fetch_array($qry))
								{
									if($_REQUEST['state']==$row['stateid'])
									{
								?>
									<option value="<?php echo $row['stateid']?>" selected="selected"><?php echo $row['statename']?></option>
								<?php
									}
									else {
										?>
									<option value="<?php echo $row['stateid']?>"><?php echo $row['statename']?></option>
									<?php
									}
								}
							}
							
						}
						?>	
					</select>
							
				
				</span>
				<script>$('#state').val(<?php echo $_REQUEST['state'];?>);</script>
			</div>
		</div>
		<div class="blue_box">
			<div class="form_field_box">
				<label for="city" id="lblCity">City:</label>
				<span id="selectedCity">
					<select name="city" id="city" style="width:145px; height:28px;" class="inputbg">
						<option value="">Select city...</option>
						<?php
						if($_REQUEST['state']!='')
						{
							$qry = mysql_query("select cityid , cityname,stateid from tbl_city where stateid='".$_REQUEST['state']."'") or die(mysql_error());
							$cnt_qry =  mysql_num_rows($qry);
							if($cnt_qry > 0)
							{
								while($row = mysql_fetch_array($qry))
								{
									if($_REQUEST['city']==$row['cityid'])
									{
									?>
										<option value="<?php echo $row['cityid']?>" selected="selected"><?php echo $row['cityname']?></option>
									<?php
									}
									else
									{
										?>
										<option value="<?php echo $row['cityid']?>"><?php echo $row['cityname']?></option>
										<?php
									}
								}
							}
						}
						?>
					</select>
				</span>
			</div>
			<div class="form_field_box">
				<label for="zip" id="lblZip">Zip Code:</label>
				<span>
				
				<input type="text" name="zip" id="zip" value="<?php echo $_REQUEST['zip']?>"  class="inputbg" />
				
				</span>
			</div>
		</div>
		<div class="blue_box">
			<div class="form_field_box_full">
				<label for="phoneNumber1" id="lblPhoneNumberPrimary">Telephone:</label>
				<span>
					
					<input type="text" name="phoneNumber1" id="phoneNumber1" value="<?php echo $_REQUEST['phoneNumber1']?>" maxlength="4" style="width:20px;" class="inputbg" /><font style="padding:10px 0px 0px 0px;"> - </font>
					
					<input type="text" name="phoneNumber2" id="phoneNumber2" value="<?php echo $_REQUEST['phoneNumber2']?>" maxlength="4" style="width:20px;"  class="inputbg" /><font style="padding:10px 0px 0px 0px;"> - </font>
					<input type="text" name="phoneNumber3" id="phoneNumber3" value="<?php echo $_REQUEST['phoneNumber3']?>" maxlength="6"  style="width:20px;"  class="inputbg" /> <font style="padding:10px 0px 0px 0px;">Ext :</font>
					<input type="text" name="extension1" id="extension1" maxlength="20" value="<?php echo $_REQUEST['extension1']?>"  style="width:30px;"  class="inputbg" />
				</span>
			</div>	
		</div>
		<div class="blue_box">
			<div class="form_field_box">
				<label for="email" id="lblEmail">Email:</label>
				<span>
				
				<input type="text" name="email" id="email" value="<?php echo $_REQUEST['email']?>"  class="inputbg" style="width:150px;" />
				
				</span>
			</div>
			<div class="form_field_box">
				<label for="emailAgain" id="lblEmailAgain">Re-enter email:</label>
				<span>
					
					<input type="text" name="emailAgain" id="emailAgain" value="<?php echo $_REQUEST['emailAgain']?>" style="width:150px;"  class="inputbg" />
					
					
					<input type="hidden" name="utype" id="utype" value="5" />
					
				</span>
			</div>
		</div>
		
		<div class="blue_box">
			<div class="bluebar_left"></div>
			<div class="bluebar_center"><span>Business Contact Information-(required)</span></div>
			<div class="bluebar_right"></div>
		</div>
		
		<div class="blue_box" style="text-align:center;">
			We verify every business for authenticity. You will be contacted by our Swapen Team for verification.
		</div>
		<div class="blue_box">
			<div class="form_field_box">
				<label for="firstName" id="lblFirstName">First Name:</label>
				<span>
				
				<input type="text" name="firstName" id="firstName" value="<?php echo $_REQUEST['firstName']?>"  class="inputbg" />
				
				</span>
			</div>
			<div class="form_field_box">
				<label for="lastName" id="lblLastName">Last Name:</label>
				<span>
				
				<input type="text" name="lastName" id="lastName" value="<?php echo $_REQUEST['lastName']?>"  class="inputbg" />
				
				</span>
			</div>
		</div>
		<div id="samename" style="display: none; color: #FF0000; float: left; font-weight: bold; text-align: center; width: 600px;">&nbsp;&nbsp;First Name and Last Name cannot be the same. </div>
		<div class="blue_box">
			<div class="form_field_box_full">
					<label for="phoneNumber4" id="lblPhoneNumberSecondary">Telephone:</label>
					<span>
						
						<input type="text" name="phoneNumber4" id="phoneNumber4" value="<?php echo $_REQUEST['phoneNumber4']?>" maxlength="4" style="width:20px;"  class="inputbg" /><font style=" padding:10px 0px 0px 0px;"> - </font>
						
						<input type="text" name="phoneNumber5" id="phoneNumber5" maxlength="4" value="<?php echo $_REQUEST['phoneNumber5']?>" style="width:20px;"  class="inputbg" /><font style="padding:10px 0px 0px 0px;"> - </font>
						
						<input type="text" name="phoneNumber6" id="phoneNumber6" maxlength="6" value="<?php echo $_REQUEST['phoneNumber6']?>" style="width:20px;"  class="inputbg" /><font style="padding:10px 0px 0px 0px;"> Ext : </font>
						
						<input type="text" name="extension2" id="extension2" maxlength="20" value="<?php echo $_REQUEST['extension2']?>"  style="width:30px;"  class="inputbg" />
					</span>
				</div>	
		</div>
		<div class="blue_box">
			<div class="form_field_box">
				<label for="businessEmail" id="lblbusinessEmail">Email:</label>
				<span>
				
				<input type="text" name="businessEmail" id="businessEmail" value="<?php echo $_REQUEST['businessEmail']?>" class="inputbg" style="width:150px;" />
				
				</span>
			</div>
			<div class="form_field_box">
				<label for="businessEmailAgain" id="lblbusinessEmailAgain">Re-enter email:</label>
				<span>
					
					<input type="text" name="businessEmailAgain" id="businessEmailAgain" value="<?php echo $_REQUEST['businessEmailAgain']?>"  class="inputbg" style="width:150px;" />
					
				</span>
			</div>
		</div>
		<div class="blue_box">
			<div class="form_field_box">
				<label for="driverLicence" id="lbldriverLicence">Driver Licence#:</label>
				<span>
				
				<input type="text" name="driverLicence" id="driverLicence" value="<?php echo $_REQUEST['driverLicence']?>" class="inputbg" />
				
				</span>
			</div>
			<div class="form_field_box">
				<a href="javascript:void(0);" id="bargain_price_more_info" onclick="show_more_info(1)">why do you need my DL#?</a>
			</div>
			<div style=" display: none; width: 400px; font-weight:bold; padding:10px; background-color:#cccccc; opacity:1;" class="user_popup" id="more_info">
				<span style="float:left; width:100%; text-align:right; margin-bottom:5px;"><label style="cursor:pointer;" onclick="$('#more_info').fadeOut('slow');">x</label></span>
				<span style="float:left; width:100%; margin-bottom:10px;" id="desc_info_n"></span>
			</div>
		</div>
		
		<div class="blue_box">
			<div class="bluebar_left"></div>
			<div class="bluebar_center"><span>Choose your username and password-(required)</span></div>
			<div class="bluebar_right"></div>
		</div>
		<div class="blue_box">
			<div class="form_field_box_full">
				<label for="userName" id="lblUserName">Create Username:</label>
				<span>
				
				<input type="text" name="userName" id="userName" value="<?php echo $_REQUEST['userName']?>" style="width:200px;" class="inputbg" />
				
				</span>
			</div>
			
		</div>
		<div class="blue_box">
			<div class="form_field_box_full">
				<label for="password" id="lblPassword">Create Password:</label>
				<span>
				
				<input type="password" name="password" id="password" style="width:200px;" class="inputbg" />
				
				</span>
			</div>
			
		</div>
		<div id="errmsg" style="color:red"></div>
		<div class="blue_box">
			<div class="form_field_box_full">
				<label for="confirmPassword" id="lblConfirmPassword">Re-enter Password:</label>
				<span>
				
				<input type="password" name="confirmPassword" id="confirmPassword"  style="width:200px;" class="inputbg" />
				
				</span>
			</div>
			
		</div>
		<div class="blue_box">
			<div class="form_field_box_full">
				<label for="secretQuestion" id="lblSecretQuestion">Pick a secret question:</label>
				<span>
					<select name="secretQuestion" id="secretQuestion" style="width:300px; height:28px;" class="inputbg">
						<option value="">Select a secret question</option>
						<?php
						$sqlSelQuestion = "select * from tbl_questions";
						$rstSelQuestion = mysql_query($sqlSelQuestion) or die(mysql_error());
						while($rowSelQuestion = mysql_fetch_array($rstSelQuestion))
						{ ?>
						<option value="<?php echo $rowSelQuestion['question_id'] ?>"><?php echo $rowSelQuestion['question'] ?></option>
						<?php } ?>
					</select>
					<script>$('#secretQuestion').val(<?php echo $_REQUEST['secretQuestion'];?>);</script>
				</span>
			</div>
			
		</div>
		<div class="blue_box">
			<div class="form_field_box_full">
				<label for="secretAnswer" id="lblSecretAnswer">Your seceret answer:</label>
				<span>
				
				<input type="text" name="secretAnswer" value="<?php echo $_REQUEST['secretAnswer']?>" id="secretAnswer" class="inputbg" />
				
				</span>
			</div>
		</div>
		<div class="blue_box">
			<div class="form_field_box_full">
				<label for="dMonth" id="lblDOB">Date of birth:</label>
				<span>
					<select name="dMonth" id="dMonth1" style="width:100px; height:28px;" class="inputbg">
						<option value="">--Month--</option>
						<option value="01">January</option>
						<option value="02">February</option>
						<option value="03">March</option>
						<option value="04">April</option>
						<option value="05">May</option>
						<option value="06">June</option>
						<option value="07">July</option>
						<option value="08">August</option>
						<option value="09">September</option>
						<option value="10">October</option>
						<option value="11">November</option>
						<option value="12">December</option>
					</select>&nbsp;&nbsp;
					<script>$('#dMonth').val('<?php echo $_REQUEST['dMonth'];?>');</script>

					<select name="dDay" id="dDay" style="width:80px; height:28px;" class="inputbg">
						<option value="">--Day--</option>
						<?php
						for($i=1;$i<=31;$i++)
						{
							if($i<=9)
							$d = '0'.$i;
							else
							$d = $i;
							?>
							<option value="<?php echo $d;?>"><?php echo $d;?></option>
							<?php
						}
						?>
					</select>&nbsp;&nbsp;
					<script>$('#dDay').val(<?php echo $_REQUEST['dDay'];?>);</script>
					<input type="dYear" name="dYear" id="dYear" value="<?php echo $_REQUEST['dYear']?>" onclick="this.value=''" style="width:40px;" maxlength="4"  class="inputbg"/>
					
					<br />
					<span class="boldGreyNotes" id="lblAgeNote" style="margin:5px 0px 10px 0px;">You must be at least 18 years old to use Swapen.</span><br/><br/>
				</span>
			</div>
		</div>
		<div class="blue_box">
			<div class="form_field_box_full">
				<label for="securityCode" id="lblSecurityCode" style="margin:10px 0px 10px 0px;">Prove you're human:</label>
				<span>
					<img id="siimage" align="left" style="padding-right: 5px; border: 0" src="securimage_show.php?sid=<?php echo md5(uniqid(time())); ?>" />
					<a tabindex="-1" style="border-style: none" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = 'securimage_show.php?sid=' + Math.random(); return false">
					<img src="images/reload.png" alt="Reload Image" border="0" onclick="this.blur()" align="bottom" /></a><br />
					
					<input type="text" name="securityCode" id="securityCode" style="width:200px;" class="inputbg" />
					
				</span>
			</div>
		</div>
		<div class="blue_box">
			&nbsp;
		</div>
		<div class="blue_box">
			<div class="form_field_box_full">
				<div class="checkbox"><input name="accept" id="accept" type="checkbox" /> </div> &nbsp;&nbsp;
				<label style="text-align:left;">I agree that:</label>
				<div id="lblAgreement" style="display:none; color:#FF0000; font-weight:bold">Acceptance of  agreement is must to register. </div>
			</div>
			<br /><br /><br />
			<ul>
				<li>I accept the <a href="" tabindex="1">User Agreement</a> and <a href="index.php?policy" target="_blank">Privacy Policy</a>.</li>
				<li>I may receive communications from swapen.</li>
				<li>I'm at least 18 years old.</li>
			</ul>
		</div>
		<div class="blue_box" style="text-align:center;">
			<input type="submit" name="submit" id="submit" value="REGISTER" class="sbmt_btn" />
		</div>
		<div id="messageAreaBottom" style="margin:10px 0px 10px 20px; float:left;"></div>
		
	</td>
  </tr>
 
</table>

	</div>
	<div class="releftbox_bot">&nbsp;</div>
	</div>
	
	<div class="rergtbox_out">
	<div class="rergtbox_top">&nbsp;</div>
	<div class="rergtbox_repeat">
		<ul class="register">
			<li>First Year FREE!
				<div class="bluebigarrow">&nbsp;</div>
			</li>
			<li>Access Dirctly To Merchants
				<div class="bluebigarrow">&nbsp;</div>
			</li>
			<li>Merchants Access Your Inventory
				<div class="bluebigarrow">&nbsp;</div>
			</li>
			<li>Search Through Wanted Iems List
				<div class="bluebigarrow">&nbsp;</div>
			</li>
			<li>Upload All Your Items at Once</font>
				<div class="bluebigarrow">&nbsp;</div>
			</li>
			<li>AND MUCH MUCH MORE<br/>AND ITS ALL FREE!
				<div class="bluebigarrow">&nbsp;</div>
			</li>
		</ul>
		
		<div class="fulldiv">
			<div class="quoteimg">&nbsp;</div>
		</div>
		<div class="fulldiv">
			<div class="quote">
			I can't believe this website is here for me to make much 
			more extra money. They are providing merchants free access 
			to my inventory list of thousands of products at no cost to me.  
			My sales have increased 30%.<br/> 
			<div style="float:right; text-align:right; margin:10px 0px 0px 0px;">Nick 37 New York</div>
			</div>
		</div>
		
		<div class="fulldiv">
			<div class="quoteimg">&nbsp;</div>
		</div>
		<div class="fulldiv">
			<div class="quote">
			When I first signed up on Swapen.com I didnt know what to
			expect. I have thousands of products in my inventory
			and I was doubtful that I could make one list within
			the excel spread to upload. I ended up being wrong and
			since then my inventory increased do to Swapen Merchant 
			demand for more products. Thanks. <br/>
			<div style="float:right; text-align:right; margin:10px 0px 0px 0px;">Sun 32 Washington</div>
			</div>
		</div>
		
		<div class="fulldiv">
			<div class="quoteimg">&nbsp;</div>
		</div>
		<div class="fulldiv">
			<div class="quote">
			The reason I'm writing today, is to inform potential
			wholesalers who are on the sidelines trying to figure out 
			if they should join Swapen.com. Let me give you my reasons for 
			staying: listings are free, I can search merchant's wanted 
			item list and make offers, and best of all I have a free 
			store link to pass around to clients. All of my online purchases 
			are done through Swapen.com. Those are my reasons, thanks Swapen. <br/>
			<div style="float:right; text-align:right; margin:10px 0px 0px 0px;">Jon 59 Texas</div>
			</div>
		</div>
		
		<div class="fulldiv">
			<div class="lock_text">Your privacy<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;is important to us...</div>
		</div>
		
		<div class="fulldiv">
			<div class="lockimg">&nbsp;</div>
		</div>
		
		<div class="fulldiv">
			<div class="privacy_txt">
			Swapen does not rent or sell your information
			to third parties without your consent. To learn 
			more, read our <a href="#" class="bluelink">privacy policy</a>
			</div>
		</div>	
		
	</div>
	<div class="rergtbox_bot">&nbsp;</div>
	</div>
</td>
</tr>
</table>

</form>
</div>
<?php
    if(empty($_REQUEST['state']))
    {
?>
	<script>
	      $(document).ready(function() {
		funSelectState('213','selectedState','1');
	       });
	</script>
<?php
    }
?>

<script>
	     
	     function show_more_info(a)
	     {
		       var pos = $('#bargain_price_more_info').position();
		       //alert(pos);
		       var nleft = parseInt(pos.left);
		       var ntop = parseInt(pos.top)+15;
		       $('#more_info').css({'left': nleft, 'top':ntop});
		       $('#desc_info_n').html('Driver License is needed for verification purposes only. This is to make sure that you are associated with the business.');
		       $('#more_info').fadeIn('slow');
		       //$('#more_info').show();
	       
	     }
</script>